package io.renren.common.enums;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * @author 葛傲锋 by 2020/12/9
 */
public enum IsDeleteEnum {

    //是否删除
    IS_DELETE(1, "删除"),
    NO_DELETE(0, "正常");

    private Integer value;

    private String desc;

    IsDeleteEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    /**
     * 根据value获取desc
     *
     * @param value
     * @return
     */
    public static String getEnumDescByValue(Integer value) {
        return Stream.of(IsDeleteEnum.values()).filter(s -> Objects.equals(value, s.getValue())).map(o -> o.getDesc()).findFirst().get();
    }
}
